#ifdef __cplusplus
#include <cstdlib>
#else
#include <stdlib.h>
#endif

#include "Game.h"
#include "Define.h"
// our Game object

const int FPS = 60; ///////////////////_______________////
const int DELAY_TIME = 1000.0f / FPS;//fixed framerate////

int main(int argc, char** argv)
{
	Uint32 frameStart, frameTime;

	TheGame::Instance()->init(WINDOW_TITLE, SDL_WINDOWPOS_CENTERED, 
		SDL_WINDOWPOS_CENTERED, SCREEN_WIDTH, SCREEN_HEIGHT, 0);
	while (TheGame::Instance()->running())
	{
		frameStart = SDL_GetTicks(); //fixed frame rate var

		TheGame::Instance()->handleEvents();
		TheGame::Instance()->update();
		TheGame::Instance()->render();

		frameTime = SDL_GetTicks() - frameStart; //fixed frame rate var

		if (frameTime < DELAY_TIME) //fixed frame rate
		{
			SDL_Delay((int)(DELAY_TIME - frameTime)); //delay to achieve fixed frame rate
		}
	}
	TheGame::Instance()->clean();

	return 0;
}